#!/bin/bash
# A simple script to "bump REL".
# Do whatever the fuck you want with this script.
#
# Usage: bump-rel path/to/spec/file

# Gotta know how to use it eh?
if [ -z "$1" ]; then
   echo "Usage: bump-rel path/to/spec/file"
   exit 1
fi

# Just to be sure.
unset REL

# If a file does not contain line containing REL= on the line beginning,
# then append 'REL=1'; otherwise, bump REL.
#
# FIXME: does not give two f*cks about duplicate REL=, not pretty, but
# practically, nothing can really go wrong - or can it?
if ! $(grep '^REL=' "$1" > /dev/null); then
   echo 'REL=1' >> "$1"
else
   source "$PWD"/"$1"
   NEWREL=$(($REL + 1))
   sed -e "s|REL=.*|REL=$NEWREL|g" -i "$1"
fi
